/**
 * 
 */
package com.googlecode.eventio.stat;

import java.util.concurrent.atomic.AtomicLong;

import com.googlecode.eventio.spi.StatisticsImplementor;

/**
 * @author steph
 * 
 */
public class StatisticsImpl implements Statistics, StatisticsImplementor {

	private final AtomicLong emitCounter = new AtomicLong();

	private final AtomicLong onCounter = new AtomicLong();

	private final AtomicLong onceCounter = new AtomicLong();

	private final AtomicLong removeCounter = new AtomicLong();

	private final AtomicLong processedReactionCounter = new AtomicLong();

	@Override
	public void emit(Object event) {
		emitCounter.incrementAndGet();
	}

	@Override
	public void on(Object event) {
		onCounter.incrementAndGet();
	}

	@Override
	public void once(Object event) {
		onceCounter.incrementAndGet();
	}

	@Override
	public void remove(Object event) {
		removeCounter.incrementAndGet();
	}

	@Override
	public void endReaction(boolean success) {
		processedReactionCounter.incrementAndGet();
	}

	@Override
	public void clear() {
		emitCounter.set(0);
		onCounter.set(0);
		onceCounter.set(0);
		processedReactionCounter.set(0);
		removeCounter.set(0);
	}

	@Override
	public long getEmitCount() {
		return emitCounter.get();
	}

	@Override
	public long getOnCount() {
		return onCounter.get();
	}

	@Override
	public long getOnceCount() {
		return onceCounter.get();
	}

	@Override
	public long getRemovedCount() {
		return removeCounter.get();
	}

	@Override
	public long getProcessedReactionCount() {
		return processedReactionCounter.get();
	}

}
